package com.ericsson.epc.modules.backup.task;

import com.ericsson.common.util.LogFileName;
import com.ericsson.common.util.LoggerUtils;
import com.ericsson.epc.modules.backup.service.EpcDataBackupService;
import com.ericsson.epc.modules.sys.entity.EPCNetElement;
import org.slf4j.Logger;

import java.util.Map;
import java.util.concurrent.CountDownLatch;

/**
 * @description:
 * @author: wangjingshi
 * @create: 2021-07-22 16:40
 */
public class ExecuteSaegwUTask implements Runnable{

    private Logger log = LoggerUtils.Logger(LogFileName.EpcDataBackupJob);
    private EpcDataBackupService epcDataBackupService;
    private EPCNetElement saegwu;
    private String date;
    private CountDownLatch latch;

    public ExecuteSaegwUTask(EpcDataBackupService epcDataBackupService, EPCNetElement saegwu, String date, CountDownLatch latch) {
        this.epcDataBackupService = epcDataBackupService;
        this.saegwu = saegwu;
        this.date = date;
        this.latch = latch;
    }

    @Override
    public void run() {
        try {
            epcDataBackupService.execSaegwUBackup(saegwu,date);
            epcDataBackupService.execSaegwLog(saegwu,date);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        } finally {
            latch.countDown();
        }
    }
}
